package com.wxd;

import com.wxd.service.HelloService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ConsumerApplication {

    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("consumer.xml");
        context.start();
        HelloService helloService = context.getBean(HelloService.class);
        // HelloService helloService = (HelloService)context.getBean("helloService");
        ExecutorService executorService = Executors.newFixedThreadPool(3);
        executorService.submit(() -> { while (true) helloService.sayHelloA(); });
        executorService.submit(() -> { while (true) helloService.sayHelloB(); });
        executorService.submit(() -> { while (true) helloService.sayHelloC(); });
    }
}
